package com.suao.web.controller.transportInfo;

import com.suao.common.annotation.Log;
import com.suao.common.core.controller.BaseController;
import com.suao.common.core.domain.AjaxResult;
import com.suao.common.core.page.TableDataInfo;
import com.suao.common.enums.BusinessType;
import com.suao.common.utils.poi.ExcelUtil;
import com.suao.transportInfo.domain.TransportInfo;
import com.suao.transportInfo.service.ITransportInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 出车信息管理Controller
 *
 * @author tyz
 * @date 2023-02-27
 */
@Api("出车信息管理")
@RestController
@RequestMapping("/transportInfo/transportInfo")
public class TransportInfoController extends BaseController
{
    @Autowired
    private ITransportInfoService transportInfoService;

    /**
     * 查询出车信息管理列表
     */
    @ApiOperation("获取出车列表")
    @PreAuthorize("@ss.hasPermi('transportInfo:transportInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TransportInfo transportInfo)
    {
        startPage();
        List<TransportInfo> list = transportInfoService.selectTransportInfoList(transportInfo);
        return getDataTable(list);
    }

    /**
     * 导出出车信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('transportInfo:transportInfo:export')")
    @Log(title = "出车信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TransportInfo transportInfo)
    {
        List<TransportInfo> list = transportInfoService.selectTransportInfoList(transportInfo);
        ExcelUtil<TransportInfo> util = new ExcelUtil<TransportInfo>(TransportInfo.class);
        util.exportExcel(response, list, "出车信息管理数据");
    }

    /**
     * 获取出车信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('transportInfo:transportInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(transportInfoService.selectTransportInfoById(id));
    }

    /**
     * 新增出车信息管理
     */
    @PreAuthorize("@ss.hasPermi('transportInfo:transportInfo:add')")
    @Log(title = "出车信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TransportInfo transportInfo)
    {
        return toAjax(transportInfoService.insertTransportInfo(transportInfo));
    }

    /**
     * 修改出车信息管理
     */
    @PreAuthorize("@ss.hasPermi('transportInfo:transportInfo:edit')")
    @Log(title = "出车信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TransportInfo transportInfo)
    {
        return toAjax(transportInfoService.updateTransportInfo(transportInfo));
    }

    /**
     * 删除出车信息管理
     */
    @PreAuthorize("@ss.hasPermi('transportInfo:transportInfo:remove')")
    @Log(title = "出车信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(transportInfoService.deleteTransportInfoByIds(ids));
    }
}
